﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace LOC
{
	class Program
	{
		static string BasePath = @"..\..\..\";

		static void Main(string[] args)
		{
			int loc = 0;
			List<string> csFiles = DirSearch(BasePath, "*.cs");
			foreach (string csFile in csFiles)
			{
				StreamReader sr = new StreamReader(csFile);
				while (!sr.EndOfStream)
				{
					sr.ReadLine();
					loc++;
				}
			}

			Console.WriteLine("LOC in {0} files for Project \"{1}\" is {2} -AVG: {3}",
				csFiles.Count, "BaseAppFx", loc, loc / csFiles.Count);
			Console.ReadLine();
		}

		static List<string> DirSearch(string dir, string expression)
		{
			List<string> files = new List<string>();
			foreach (string d in Directory.GetDirectories(dir))
			{
				foreach (string f in Directory.GetFiles(dir, expression))
				{
					files.Add(f);
				}
				files.AddRange(DirSearch(d, expression));
			}
			return files;
		}
	}
}
